<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增字段枚举')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-fieldEnum-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">枚举名称：</label>
                <div class="col-sm-8">
                    <input name="enumName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">枚举值：</label>
                <div class="col-sm-8">
                    <input name="enumValue" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">枚举介绍：</label>
                <div class="col-sm-8">
                    <textarea name="description" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">字段：</label>
                <div class="col-sm-8">
                    <select id="fieldId" name="fieldId" class="form-control">

                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "fieldEnum/fieldEnum";
        var fieldInfoList = [[${fieldList}]];
        $("#form-fieldEnum-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-fieldEnum-add').serialize());
            }
        }
        $(function () {
            if (fieldInfoList && fieldInfoList.length > 0) {
                for (var i=0; i<fieldInfoList.length; i++) {
                    $("#fieldId").append('<option value="'+fieldInfoList[i].id+'">'+fieldInfoList[i].fieldName + '('+fieldInfoList[i].tableName+')</option>')
                }
            }
        })
    </script>
</body>
</html>